<% availableModels ||= available_models %>

<%= content_for :javascript do %>
    
    //apply events when opening the embed popover
    $('.embed').on('shown.bs.popover', function () {
    $('button#btn_copy_embed').zclip({
    path:'/assets/ZeroClipboard.swf',
    copy:function(){
    return $('#textarea_for_iframe').text();
    },
    afterCopy: function(){}
    });

    $("#textarea_for_iframe").mouseup(function(e){
    // fixes safari/chrome problem
    e.preventDefault();
    }).focus(function(e){
    mytxt = $(this).text();
    $(this).select();
    }).click(function(e){
    mytxt = $(this).text();
    $(this).select();
    });

    });

    $('.share').on('shown.bs.popover', function () {
    $('button#btn_copy_share').zclip({
    path:'/assets/ZeroClipboard.swf',
    copy:function(){
    return $('#input_with_shorturl').val();
    },
    afterCopy: function(){}
    });

    $("#input_with_shorturl").mouseup(function(e){
    // fixes safari/chrome problem
    e.preventDefault();
    }).focus(function(e){
    mytxt = $(this).text();
    $(this).select();
    }).click(function(e){
    mytxt = $(this).text();
    $(this).select();
    });

    });

    $('.delete').popover({
      html : true,
      content: function() {
      return $('.contentdelete').html();
      },
      container: ".actions_layout_show"
    });

<% end %>


<script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function () {
        $(".with_tooltip").tooltip({placement: 'bottom'});
    });
</script>

<div class="btn-group actions_layout_show">
  <!--remove-->
  <% if user_signed_in? and can?(:destroy, @event) %>
      <button class="with_tooltip delete btn" data-toggle="popover" data-container="body" title="<%= t('excursion.actions.delete') %>" aria-hidden="true">
        <i class="fa fa-trash-o"></i>
      </button>
  <% end %>

  <div class="contentdelete" style="display: none">
    <p class="delete_p"><i class="fa fa-trash-o"></i> <%= t('event.confirm_delete') %></p>
    <div class="actions">
      <a class="btn btn_cancel closepopover"><%= t('cancel') %></a>
      <%= link_to t('excursion.actions.delete'), @event, :method => :delete, :class => 'btn btn-primary' %>
    </div>
  </div>

  <% if @event.streaming %>
      <!-- STREAMING CODE  -->
  <% else %>
      <!--mashme-->
      <%= render :partial => 'events/button-mashme' %>
  <% end %>
  <!--categoriess-->

  <% if user_signed_in? and availableModels.include? "Category" %>
      <%= render partial: 'categories/category_modal_viewer', :locals => {:remote => true, :item => @event} %>
      <button id="AddCategory" role="button" class="categorize_select btn with_tooltip" data-toggle="modal" data-target="#categories_viewer_modal" title="<%= t('category.modalLabel') %>" aria-hidden="true">
        <i class="fa fa-th-large"></i></button>
  <% end %>

</div>

<ul class="nav nav-tabs tooltab">
  <li class="<%= document_details_tab_class document, :info %>">
    <%= link_to (raw("<i class='fa fa-align-left'></i> <span class='hidden-sx'>")) + t('document.details.info') + raw("</span>"), '#document-info', 'data-toggle' => 'tab' %>
  </li>
  <!--edit info-->
  <% if user_signed_in? and (can? :update, @event) %>
      <li class="<%= document_details_tab_class document, :edit %>">
        <%= link_to (raw("<i class='fa fa-edit'></i> <span class='hidden-xs'>")) + t('document.actions.edit')+ raw("</span>"), '#document-edit', 'data-toggle' => 'tab' %>
      </li>
  <% end %>
  <li>
    <a href="#tab3" data-toggle="tab">
      <i class="fa fa-share"></i>
        <span class=" hidden-xs">
          <%= t('excursion.actions.share') %>
        </span>
    </a>
  </li>
  <li>
    <a href="#tab5" data-toggle="tab">
      <i class="fa fa-flag"></i>
          <span class=" hidden-xs">
            <%= t('excursion.actions.spam') %>
          </span>

    </a>
  </li>
</ul>
</div>
<!--vistas-->
<!--div class="viewsAndCount">
  <%#= render partial: 'objects/counters', locals: { object: @event } %>
  <div class="views">
    <%= @event.visit_count.to_s %>
    <span>
      <%#=t('follow.views')%>
    </span>   
  </div>
  <div class="like">    
    <div class="count"><%= @event.post_activity.likes.count.to_s %></div>
    <%= link_like(@event.post_activity) %>
  </div>
</div-->

<h2>
  <%= @event.title %>
</h2>

<div class="tab-content">
  <div class="tab-pane <%= document_details_tab_class document, :info %>" id="document-info">
    <div class="toggler">
      <%= render partial: "events/info", locals: {document: document} %>
    </div>
  </div>


  <!-- tab2 / editar -->
  <% if can? :update, @event %>
      <div class="tab-pane <%= document_details_tab_class document, :edit %>" id="document-edit">
        <div class="content_edit">
          <%= render partial: 'events/edit_form', locals: {event: @event} %>
        </div>
      </div>


      <%= content_for :javascript do %>
          $('a[href="#document-edit"]').on('shown', function (e) {
          $('#editdate').data('datetimepicker').setLocalDate(new Date(Date.parse("<%= @event.start_at.iso8601 %>")));
          $('#edithourinit').data('datetimepicker').setLocalDate(new Date(Date.parse("<%= @event.start_at.iso8601 %>")));
          $('#edithourfinish').data('datetimepicker').setLocalDate(new Date(Date.parse("<%= @event.end_at.iso8601 %>")));  
          });
      <% end %>
  <% end %>


  <!-- tab3 / share -->
  <div class="tab-pane contentShare" id="tab3">

    <div class="form-group">
      <% shortURL = short_url (request.env['HTTP_HOST'].sub(/^(m|www)\./, '') + event_path(@event)) %>
      <input class="form-control" id="input_with_shorturl" type="text" value="<%= shortURL %>"/>
      <!-- <div class="input-group-addon">
        <button id="btn_copy_share" href="#" data-toggle="tooltip" data-placement="right" title="<%= t('copy_to_clip') %>">
          <i class="fa fa-copy"></i>
        </button>
      </div> -->
    </div>
    <div class="social_toolbar_excursion">
      <div class="social">
        <%= render :partial => 'shareon/twitter', :locals => {:url => shortURL, :counturl => (request.protocol + request.env['HTTP_HOST'].sub(/^(m|www)\./, '') + event_path(@event))} %>
      </div>
      <div class="social">
        <%= render :partial => 'shareon/facebook', :locals => {:url => shortURL} %>
      </div>
      <div class="social">
        <%= render :partial => 'shareon/gplus', :locals => {:url => shortURL} %>
      </div>
      <div class="social">
        <%= render :partial => 'shareon/email', :locals => {:url => shortURL, :title => @event.title, :name => (user_signed_in? ? current_subject.name : '')} %>
      </div>
    </div>
  </div>


  <!-- tab5 / spam -->

  <div class="tab-pane" id="tab5">
    <% @activity_object = @event.activity_object %>
    <%= render '/spam_report/form' %>
  </div>

</div>